package com.czf.alibaba_seata_provider2.service;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.czf.alibaba_seata_provider2.dao.db2.Busi1Dao;
import com.czf.alibaba_seata_provider2.dao.df;
import com.czf.alibaba_seata_provider2.entity.BusiEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author: create by czf
 * @version: v1.0
 * @description: com.czf.apollo.service
 * @date: 2020-03-04 20:35
 **/
@Service
public class BusiServiceImpl extends ServiceImpl<Busi1Dao, BusiEntity> implements IBusiService{

    @Resource
    Busi1Dao busi1Dao;

    @Override
    public List<BusiEntity> getAllBusi() {
        BusiEntity be = new BusiEntity();
        be.setId("34");
        be.setBusiName("天空蓝");

        System.out.println("结果1：" + JSON.toJSONString(busi1Dao.selectById("1")));
        System.out.println("自定义语句：" + JSON.toJSONString(busi1Dao.getId("3")));
        return null;

    }

//    @Transactional(transactionManager="db1TransactionManager")
    @Transactional
    @Override
    public int insertBudi(BusiEntity busi) {
        //这是一个成功的插入
        BusiEntity busi1 = new BusiEntity();
        busi1.setId("2222");
        busi1.setBusiName("诸葛亮饼店");
        busi1.setCreateTime(new Date());
        busi1Dao.insert(busi1);

        return 10;
    }

}
